<%@ page language="java" contentType="text/html; charset=utf-8" import="java.util.*,javaBean.Message"
		 pageEncoding="utf-8"%>
<%@ page import="useBean.MessageDB" %>
<%@ page import="javaBean.Detail" %>
<!DOCTYPE html>
<html lang="en">

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>留言板,享你所想</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="./css/MessageDetail.css">
</head>

<body>
	<%
		String mid = request.getParameter("mid");
		System.out.println("mid  " + mid);
		Message message = MessageDB.selectMessagem(mid);
	%>
	<% System.out.println("message == " + message); %>
	<div class="contact-form">
	<h1>主题：<%= message.gettitle() %></h1>
		<div class="txtb">
			<h2>内容：</h2>
			<p><%= message.getcontext() %></p>
		</div>

	
	<h3>评论：</h3>
   <%
   			 ArrayList dL=(ArrayList)request.getAttribute("DetailList");
	%>
	
	<% if (dL != null){
		System.out.println("detail list " + dL);
		for (int i = 0; i < dL.size(); ++i ){

				Detail detail = (Detail)dL.get(i);
				
				if(detail.getmid().equals(mid)){
	%>
	<div class="txtb">
	<h3>回复:</h3>
		<p>用户: <%= detail.getcuser() %></p>
		<p>评论：<%= detail.getcomment() %></p>
		<p>时间: <%= detail.getctime() %></p>
	</div>
	<%
		if(detail.getcuser().equals(session.getAttribute("user_name")))
		{

	%>
	<p><a href="/message_board/DeleteReplyServlet?cid=<%= detail.getcid() %>&mid=<%= detail.getmid()%>"><button > 删除 </button></a></p>

	<%}%>
	<% } %>
	<%}	} %>

	<div>
	<form action="LeaveDetailServlet" method="post">
		<input type="hidden" name="action" value="leave">	


		<div class="txtb">
			<textarea name="comment" cols="60" rows="4" required></textarea><br>
		</div>
		<input type="hidden" name="mid" value="<%= mid %>">
		<div class="txta">
			<button class="btn" type="submit">提交</button>
		</div>

	</form>
	</div>
</div>
</body>
</html>